﻿import mx.utils.Delegate;
class cn.eminia.ComboClassV1.Combo {
	var input:MovieClip;
	var popup:MovieClip;
	var ss;
	var ctrl;
	function Combo(input, popup) {
		if (input.constructor != MovieClip) {
			throw new Error('!!! Combo.input != MC');
		}
		if (popup.constructor != MovieClip) {
			throw new Error('!!! Combo.popup != MC');
		}
		this.input = input;
		this.popup = popup;
		// 
	}
	function updateSS(id, old, now) {
		if (now) {
			checkOutClick();
		} else {
			delCtrl();
		}
	}
	function checkOutClick() {
		var dd = _root.getNextHighestDepth();
		ctrl = _root.createEmptyMovieClip('mc'+dd, dd);
		ctrl.onMouseDown = Delegate.create(this, function () {
			//trace('onMouseDown');
			if (!input.hitTest(_root._xmouse, _root._ymouse) && !popup.hitTest(_root._xmouse, _root._ymouse)) {
				ss = 0;
				//trace('33333333 '+ss)
				delCtrl();
			}
		});
	}
	function delCtrl() {
		delete ctrl.onMouseDown;
		removeMovieClip(ctrl);
	}
}
